package com.zhengyisky.comsumer;

import com.rabbitmq.client.Channel;
import com.zhengyisky.pojo.Order;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
@RabbitListener( queues = "queue-2112a-2")
@Slf4j
public class Consumer2 {

    @RabbitHandler
    public void consumer(Order order, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) Long tag) throws IOException {
        log.info("消费者2,有新订单待审批,订单编号:{}", order);
        channel.basicAck(tag, true);
    }

}
